/* file minunit_example.c */

#include <stdio.h>
#include "minunit.h"
#include "../source/logic.c"

int tests_run = 0;

static char * test_calculatePrice() {	
	//test edge cases 
	assert("error, 0 kg not calculated correctly", calculatePrice(0.0f) == 0.0f);
	assert("error, 99984 kg not calculated correctly", calculatePrice(99984.0f) == 244960.8f);
	assert("error, .25389 kg not calculated correctly", calculatePrice(0.25389f) == .888615f);

	//test negatives
	assert("error, -2.49 kg not calculated correctly", calculatePrice(-2.49f) == -8.715f);
	assert("error, -2.5 kg not calculated correctly", calculatePrice(-2.5f) == -8.75f);
	assert("error, -2.51 kg not calculated correctly", calculatePrice(-2.51f) == -8.785f);
	assert("error, -4.9 kg not calculated correctly", calculatePrice(-4.9f) == -17.15f);
	assert("error, -5 kg not calculated correctly", calculatePrice(-5.0f) == -17.5f);
	assert("error, -5.1 kg not calculated correctly", calculatePrice(-5.1f) == -17.85f);
	assert("error, -0.01 kg not calculated correctly", calculatePrice(-0.01f) == -.035f);
	//test key values
	assert("error, 2.49 kg not calculated correctly", calculatePrice(2.49f) == 8.715f);
	assert("error, 2.5 kg not calculated correctly", calculatePrice(2.5f) == 7.125f);
	assert("error, 2.51 kg not calculated correctly", calculatePrice(2.51f) == 7.1535f);
	assert("error, 4.9 kg not calculated correctly", calculatePrice(4.9f) == 13.965f);
	assert("error, 5 kg not calculated correctly", calculatePrice(5.0f) == 14.25f);
	assert("error, 5.1 kg not calculated correctly", calculatePrice(5.1f) == 12.495f);
	assert("error, 0.01 kg not calculated correctly", calculatePrice(0.01f) == .035f);
	
	return 0;
}


static char * all_tests() {
	run_test(test_calculatePrice);
	return 0;
}

int main(int argc, char **argv) {
	char *result = all_tests();
	if (result != 0) {
		printf("%s\n", result);
	}
	else {
		printf("ALL TESTS PASSED\n");
	}
	printf("Tests run: %d\n", tests_run);
	
	return result != 0;
}
